/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ProductFrame.java
 *
 * Created on 2011-8-22, 20:53:47
 */
package com.securitytrace.popupwindow;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;
import javax.swing.JFrame;

import com.securitytrace.client.ManagerClient;

/**
 *
 * @author Administrator
 */
public class ProductWindow extends JDialog {

	private static final long serialVersionUID = 6737027682075583410L;
	private ManagerClient managerClient;
	/** Creates new form ProductFrame */
    public ProductWindow(JFrame frame,boolean flag) {
    	super(frame,flag);
    	managerClient = (ManagerClient)frame;
        initComponents();
        int parentWidth = (int)managerClient.getLocation().getX();
        int parentHight = (int)managerClient.getLocation().getY();
        int width = this.getWidth();
        int hight = this.getHeight();
        this.setLocation(parentWidth+width/2, parentHight+hight/2);
        init();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        productPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        productTextField = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        productTextArea = new javax.swing.JTextArea();
        productSubmitButton = new javax.swing.JButton();
        productResetButton = new javax.swing.JButton();

        //setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jLabel1.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel1.setText("产  品  信  息");
        jLabel2.setText("产品类别：");
        jLabel3.setText("类别描述：");
        productTextArea.setColumns(20);
        productTextArea.setLineWrap(true);
        productTextArea.setRows(5);
        jScrollPane1.setViewportView(productTextArea);
        productSubmitButton.setText("确  定");
        productResetButton.setText("取  消");

        javax.swing.GroupLayout productPanelLayout = new javax.swing.GroupLayout(productPanel);
        productPanel.setLayout(productPanelLayout);
        productPanelLayout.setHorizontalGroup(
            productPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(productPanelLayout.createSequentialGroup()
                .addGroup(productPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(productPanelLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(productTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, productPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(productPanelLayout.createSequentialGroup()
                            .addGap(141, 141, 141)
                            .addComponent(jLabel1))
                        .addGroup(productPanelLayout.createSequentialGroup()
                            .addGap(54, 54, 54)
                            .addComponent(jLabel3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE))))
                .addContainerGap(128, Short.MAX_VALUE))
            .addGroup(productPanelLayout.createSequentialGroup()
                .addGap(97, 97, 97)
                .addComponent(productSubmitButton)
                .addGap(65, 65, 65)
                .addComponent(productResetButton)
                .addContainerGap(141, Short.MAX_VALUE))
        );

        productPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jScrollPane1, productTextField});

        productPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2, jLabel3});

        productPanelLayout.setVerticalGroup(
            productPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(productPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(30, 30, 30)
                .addGroup(productPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(productTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(productPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(productPanelLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(productPanelLayout.createSequentialGroup()
                        .addGap(37, 37, 37)
                        .addComponent(jLabel3)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                .addGroup(productPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(productResetButton)
                    .addComponent(productSubmitButton))
                .addContainerGap())
        );

        productPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel2, jLabel3, productTextField});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(productPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(productPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    void init() {
    	productResetButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ProductWindow productFrame = getInstance();
				productFrame.dispose();
			}
		});
    }
    
    public ProductWindow getInstance() {
    	return this;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel productPanel;
    private javax.swing.JButton productResetButton;
    private javax.swing.JButton productSubmitButton;
    private javax.swing.JTextArea productTextArea;
    private javax.swing.JTextField productTextField;
    // End of variables declaration//GEN-END:variables
    /**以下为get/set方法**/
	public ManagerClient getManagerClient() {
		return managerClient;
	}
	public void setManagerClient(ManagerClient managerClient) {
		this.managerClient = managerClient;
	}
	public void setProductSubmitButton(ActionListener listener) {
		this.productSubmitButton.addActionListener(listener);
	}
	public javax.swing.JTextArea getProductTextArea() {
		return productTextArea;
	}
	public void setProductTextArea(javax.swing.JTextArea productTextArea) {
		this.productTextArea = productTextArea;
	}
	public javax.swing.JTextField getProductTextField() {
		return productTextField;
	}
	public void setProductTextField(javax.swing.JTextField productTextField) {
		this.productTextField = productTextField;
	}
}
